﻿@model CallCenter.Data.Models.RegisterViewModel

@{
    ViewBag.Title = "Register";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<style>
    .form-control {
        width: 25%;
    }
</style>
@*@foreach (var item in Model)
{
    <tr>
        <td><input type="type" name="name" value=" " onclick=""/></td>
        <td>Parent</td>
    </tr>
}*@


@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    @Html.AntiForgeryToken()
    @*<h4>Create a new account.</h4>*@
    <hr />
        <div class="form-group">
            <label class="col-md-2 control-label" style="font-size: 20px;">
                Create User
            </label>
        </div>
    if (!string.IsNullOrEmpty(@ViewBag.Message))
    {
        <div class="validation-summary-errors text-danger">
            <ul>
                <li>
                    @ViewBag.Message
                </li>
            </ul>
        </div>
    }
    @Html.ValidationSummary("", new { @class = "text-danger" })
    <div class="form-group">
            @Html.Label("Contacts", new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @*@Html.DropDownList("Name")*@
                @Html.DropDownList("ContactId", (IEnumerable<SelectListItem>)ViewBag.ContactName, new { @class = "form-control" })
            </div>
        </div>
    
    <div class="form-group">
        @Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
        <div class="col-md-10">
            @Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
        </div>
    </div>


        <div class="form-group">
            @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.PasswordFor(m => m.Password, new { @class = "form-control" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" })
            </div>
        </div>

        <div class="form-group">
            @Html.Label(" User Role", new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @*@Html.DropDownList("Name")*@
                @Html.DropDownList("RoleId", (IEnumerable<SelectListItem>)ViewBag.RoleId, new { @class = "form-control" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" class="btn btn-default" value="Register" />
            </div>
        </div>


}
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
<script>
    $("#ContactId").change(function () {
        $.post("/Account/GetUserByContact",
         {
             ContactId: $("#ContactId").val()
         },
        
         function (data) {
             $("#Email").val(data.email);
             $("#UserName").val(data.email);
         });

      
    });
</script>
